package com.training2.bookstore.log.model;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAspect {
	@Pointcut("@annotation(org.springframework.web.bind.annotation.GetMapping)||@annotation(org.springframework.web.bind.annotation.PostMapping)")
	void LogPoint() {}
	
	
	@Around(value = "LogPoint()")
	public Object logIt(ProceedingJoinPoint jp) throws Throwable {
		Object[] args = jp.getArgs();
	//log
		Object rst = jp.proceed(args);
		//exception
		return rst;
		
	}

}
